package asteroids.expression;

import asteroids.model.programs.*;

import asteroids.*;

public class GetRadiusExpression extends NumericExpression {

	public GetRadiusExpression(Expression exp) {
		super(exp);

	}

	public double getValue(Program program) {
		this.updateArguments(program);
		if (this.arg1 instanceof EntityExpression) {

			return ((EntityExpression) arg1).getValue(program).getSize();
		} else if (this.arg1 instanceof Variable
				&& ((Variable) this.arg1).getRef(program) instanceof EntityExpression) {
			return ((FlyingObject) ((Variable) arg1).getValue(program))
					.getSize();
		} else {
			return 0.001;
		}
	}

	@Override
	public String toString(Program program) {
		Double d = this.getValue(program);
		String s = Double.toString(d);
		return "" + s;
	}

}
